package com.example.sqlite.user.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.sqlite.user.dao.UserDao;
import com.example.sqlite.user.dao.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserDao userDao;

    public UserEntity getUserEntity(Integer id) {
        return userDao.findById(id);
    }

    public List<UserEntity> getUserEntityList(UserEntity userEntity) {
        return userDao.findByWhere(null, userEntity);
    }

    public List<UserEntity> getUserEntityPageList() {
        IPage<?> page = new Page<>();
        page.setSize(2);
        page.setCurrent(1);
        UserEntity userEntity = new UserEntity();
        return userDao.findByWhere(page, userEntity);
    }
}
